<template>
  <div class="maskCenter">
    
    <!-- <rules-manage v-if="editFlag" :isBrowse="isBrowse" @hide="hide" @query='search' :id="id" :titleName="titleName" :dictionaryId="dictionaryId"></rules-manage> -->
    <div :class="windowShow ? 'systemDialog' : 'systemDialog-hide'">
      <div class="dialog-header" v-winmove>
        <span>新增数据源</span>
        <el-tooltip
          class="item"
          effect="dark"
          content="关闭"
          placement="top-start"
        >
          <span
            class="icon iconfont iconbiaoqianlan-guanbi"
            @click="close"
          ></span>
        </el-tooltip>
      </div>
      <div class="dialog-body content">
        <div class="attribute">
          <el-form
            class="systemForm"
            ref="form"
            :model="form"
            label-width="75px"
            size="mini"
          >
            <el-form-item label="名称:">
              <el-input
                v-model="form.name"
                placeholder="请输入微服务名称"
                style="width: 147px"
                class="systemInput"
              ></el-input>
            </el-form-item>
            <el-form-item label="数据源:">
              <!-- <el-input
                v-model="form.dataSource"
                placeholder="请输入数据源名称"
                style="width: 147px"
                class="systemInput"
              ></el-input> -->
              <el-select v-model="form.dataSource" placeholder="请选择"
                style="width: 147px"
                class="systemInput"
                >
                <el-option
                  v-for="item in nameOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="激活状态:">
              <el-select
                v-model="form.status"
                placeholder="请选择"
                style="width: 147px"
                class="systemInput"
              >
                <el-option
                  v-for="item in typeOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <div class="dialog-footer right">
        <span class="systemButtonConfirm" @click="originCommit">确认</span>
        <span class="systemButtonConfirm" @click="close">取消</span>
      </div>
    </div>
  </div>
</template>

<script>
import winmove from "@/directives/winmove";
import { dataOriginAdd } from '@/system/api/listStructure.js'
export default {
  name: "dataOriginAdd",
  directives: {
    winmove,
  },
  components: {
  },
  props: {},
  data() {
    return {
      nameOptions: [
        {
        value: 'mysql',
        label: 'mysql'
       }, {
        value: 'oracle',
        label: 'oracle'
       }
      ],
      fileType: "承包合同附件",
      titleName: "附件列表",
      showManage: false,
      dropmenus: [],
      typeOptions: [
        {
          value: 0,
          label: "关闭",
        },
        {
          value: 1,
          label: "开启",
        },
      ],
      windowShow: true,
      showForm: false,
      form: {
        dataSource: "",
        name: "",
        status: ""
      },
    };
  },
  methods: {
    close() {
      this.windowShow = false;
      setTimeout(() => {
        this.$emit("hide");
      }, 400);
    },
    originCommit() {
      try{
        dataOriginAdd(this.form)
        this.$message.success('新增成功')
        this.$emit('ok')
      }catch{
        this.$message('新增失败')
      }
      this.windowShow = false;
    }
  }
}
</script>

<style scoped>
.content {
  display: flex;
  flex-direction: row;
}
.content /deep/ .page-menu {
  background: var(--system-page-content-bgc);
  width: 100%;
  border: none;
  padding-top: 0px;
}


.attribute {
  width: 480px!important;
  margin-left: 12px;
  background: var(--dialog-buttonBox-back-color);
  border: 1px solid var(--div-border-color);
  border-radius: 6px;
  padding: 16px;
}
.forms-list {
  background: rgba(255, 255, 255, 0);
  border: 1px solid var(--div-border-color);
  border-radius: 6px;
}
.definition-name {
  height: 16px;
  line-height: 16px;
  font-size: 16px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: var(--system-form-text-color);
  margin: 16px;
  text-align: left;
}

.definition-name .myForm .el-input--mini .el-input__inner {
  height: 32px;
  line-height: 32px;
  border: 1px solid var(--input-border-color);
  box-shadow: 0px 10px 20px 0px rgba(204, 204, 204, 0.1),
    0px -10px 20px 0px rgba(204, 204, 204, 0.1);
  border-radius: 4px;
}
.systemDialog {
  width: 540px;
  height: 584px;
}
.systemDialog-hide {
  width: 540px;
  height: 584px;
}
.page-menu .page-menu-search .addicon {
  text-align: center;
}
.systemInput {
  width: 300px!important;
  height: 100px!important;
}
</style>